<%-- 
    Document   : detailClasse
    Created on : 27 mai 2014, 13:58:40
    Author     : erboutel
--%>
<jsp:useBean id="utilisateur" class="fr.p10.miage.gestionabsence.model.Utilisateur" scope="session"/>
<%@page import="fr.p10.miage.gestionnote.model.Note"%>
<%@page import="fr.p10.miage.gestionnote.model.EcEtudiant"%>
<%@page import="fr.p10.miage.gestionnote.model.Controle"%>
<%@page import="java.util.List"%>
<%@page import="fr.p10.miage.gestionnote.model.EcIntervenant"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<!DOCTYPE html>
<html lang="fr">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="">
        <meta name="author" content="">
        <link rel="shortcut icon" href="">
        <title>Consulter la classe</title>
        <link href="css/bootstrap.css" rel="stylesheet">
        <link href="css/font-awesome.css" rel="stylesheet">
        <link href="css/index-bo.css" rel="stylesheet">
    </head>

    <body class="skin-black fixed">
        <style>
            .table-striped > tbody > tr > .danger,
            .table-striped > tbody > .danger > td,
            .table-striped > tbody > .danger > th {
              background-color: #f2dede !important;
            }
        </style>
        <%
            EcIntervenant ecIntervenant = (EcIntervenant) request.getAttribute("ecIntervenant");
        %>
        <%@include file="../../../header.jsp" %>
        <div class="wrapper row-offcanvas row-offcanvas-left">
            <%@include file="../../../asideLeft.jsp" %>
            <aside class="right-side">   
                <section class="content-header">
                     <h1>Consultation de la classe</h1>
                     <html:link action="/ec-detail" linkName="Detail ec">
                        <button type="button" class="btn btn-default pull-right" style="background-color: #eee; margin-bottom: 15px;" ><span class="glyphicon glyphicon-chevron-left" ></span> Retour</button>
                            <html:param name="idec">
                                <% out.print(ecIntervenant.getIdec()); %>
                            </html:param>
                            <html:param name="idp">
                                <% out.print(ecIntervenant.getIdP()); %>
                            </html:param>
                      </html:link>
                </section>
                <section class="content">
                    <div class="container-fluid">
                        <%
                            List<Controle> listControles = ecIntervenant.getControles();
                        %>
                        <legend>Liste des contrôles par etudiants</legend>
                        <html:errors property="commentaireTaille"/>
                        <form action="ec-ajouter-commentaire-etudiant.do" method="post">
                            <input type="hidden" name='idp' value="<%=String.valueOf(ecIntervenant.getIdP())%>">
                            <input type="hidden" name='idec' value="<%=String.valueOf(ecIntervenant.getIdec())%>">
                            <input type="hidden" name='sizeListeEtudiant'
                                   value="<%=String.valueOf(ecIntervenant.getEtudiants().size())%>">
                            <table class="table table-striped table-bordered">
                                <tr>
                                    <th>Elève</th>
                                    <%
                                        for(int i=0; i<listControles.size(); i++) {
                                            out.print("<th><u>"+listControles.get(i).getLabel()+"</u> (Coeff:"+listControles.get(i).getCoefficient()+") </th>");
                                        }
                                    %>
                                    <th>Moyenne (/20)</th><th>Commentaire</th>
                                </tr>
                                <%
                                    List<EcEtudiant> listEtudiant = ecIntervenant.getEtudiants();
                                    Note note = null;
                                    for(int i=0; i<listEtudiant.size(); i++) {
                                 %>
                                        
                                        <input type="hidden" name='<%= "idEtudiant" + i%>' class="form-control"
                                       value="<%=String.valueOf(ecIntervenant.getEtudiants().get(i).getId())%>">
                                        <tr>
                                        <td><%=listEtudiant.get(i).getNom()+" "+listEtudiant.get(i).getPrenom()%></td>
                                        
                                 <%
                                        for(int j=0; j<listControles.size(); j++) 
                                        {
                                            note = listControles.get(j).getNoteByEtudiantId(listEtudiant.get(i).getId());
                                            if(note !=null)
                                            {
                                                if(note.getDispense())
                                                {
                                 %>
                                               <td>Dispensé</td>
                                 <%
                                                }else
                                                {
                                 %>
                                              <td ><%=note.getNote()%>/<%=listControles.get(j).getEchelle()%></td>
                                 <%
                                                }
                                            }
                                            else
                                            {
                                 %> 
                                                <td>Pas de Note renseignée</td>
                                 <%
                                            }
                                        }
                                        float moyeEtudiant = ecIntervenant.calculMoyenneEcByEtudiantId(listEtudiant.get(i).getId());
                                 %>
                                        
                                        <td <%if(moyeEtudiant<20/2){%>class="danger"<%}%>><%=moyeEtudiant%></td>
                                        <td>
                                            <input type="text" class="form-control" name="<%= "commentaire" + i%>" value="<%=String.valueOf(ecIntervenant.getCommentaireByEtudiantId(ecIntervenant.getEtudiants().get(i).getId()))%>">
                                        </td>    
                                        </tr>
                                 <%
                                    }
                                %>
                            </table>
                            <button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-ok" ></span> Valider Modification</button>
                        </form>
                    </div>
                </section>
            </aside>
        </div>
        <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> 
        <script src="js/bootstrap.js"/></script>
        <!--[if lt IE 9]>
            <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
            <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->
        <script src="js/app.js"/></script>
</body>
</html>
